package io.geekidea.boot.shop.controller.app;

import io.geekidea.boot.framework.page.Paging;
import io.geekidea.boot.framework.response.ApiResult;
import io.geekidea.boot.shop.query.app.AppOrderQuery;
import io.geekidea.boot.shop.service.base.api.OrderService;
import io.geekidea.boot.shop.vo.app.AppOrderVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Appnull 控制器
 *
 * @author geekidea
 * @since 2024-10-27
 */
@Slf4j
@RestController
@Tag(name = "Appnull")
@RequestMapping("/app/order")
public class AppOrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 获取Appnull详情
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取Appnull详情")
    @PostMapping("/getAppOrder/{id}")
    public ApiResult<AppOrderVo> getAppOrder(@PathVariable Integer id) {
        log.info("获取Appnull详情：{}", id);
        AppOrderVo appOrderVo = orderService.getAppOrderById(id);
        return ApiResult.success(appOrderVo);
    }

    /**
     * 获取Appnull分页列表
     *
     * query
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取Appnull分页列表")
    @PostMapping("/getAppOrderPage")
    public ApiResult<AppOrderVo> getAppOrderPage(@Valid @RequestBody AppOrderQuery query) {
        log.info("获取Appnull分页列表：{}", query);
        Paging<AppOrderVo> paging = orderService.getAppOrderPage(query);
        return ApiResult.success(paging);
    }

}
